Repository navigation
Hyprland 上支持快捷键映射:注册成合成器自己的全局快捷键 - #1
Merged
Merged
Conversation
Wayland 看不到全局键盘,之前 Wayland 上设置页不显示快捷键映射。Hyprland 提供 hyprland-global-shortcuts-v1,由合成器把按下的触发键交给流界: - 平台层新增 LocalShortcut:后台线程注册快捷键对象,并用 hyprctl 把触发键绑成 global, app.flowacross.desktop:<id>(按物理键位;0.57 起的 Lua 配置和更早的 老式配置都支持);重载配置后自动重绑,退出时撤销。 - 引擎只把现在真发得出去的映射注册过去(目标连着、认得 KeyStroke、共享没暂停), 发不出去的触发键照常交给原来的去处;按下后走 Controller::run_shortcut,和本机 捕获是同一条路;没发出去时限频提示。 - 设置页在 Hyprland 上重新显示快捷键映射并说明绑定方式;Limits 新增 local_mapping。 - 架构第 5、12 节和路线图同步更新,第三方依赖清单重新生成。 验证:flow-platform 单测、clippy、前端构建通过;开发机 Hyprland 0.57.2 上实测 注册、按下回调、撤销;按下的映射真的发到另一台电脑尚未在真机上验证。
pingod
force-pushed
the
hyprland-mapping
branch
from
November 26, 2026 00:01
0df6ee3 to
fc8a271
Compare
Hearion
pushed a commit
that referenced
this pull request
Nov 28, 2026
PR #1 把 configure 挪到了状态锁外,两个线程同时同步时旧配置可能后写入。改回锁内; 注册到 Hyprland 的那一步第一次要连合成器、调 hyprctl,仍在锁外做,用序号保证顺序。 补注释说明 unbind 只会删同样用 code: 写的绑定。
Hearion
pushed a commit
that referenced
this pull request
Nov 28, 2026
Owner
|
感谢贡献!已合并,并随 v0.2.6 发布。 合并时我在你的提交之上补了一处修改(dc9db58): 有两点想请你帮忙确认:
如果方便,装上 0.2.6 后在 Hyprland 上再试一下,有问题直接开 issue。 |
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Wayland 下普通程序看不到全局键盘,所以 Hyprland 上的快捷键映射一直不能用(FlowAcross-releases #4)。Hyprland 提供了
hyprland-global-shortcuts-v1:程序注册快捷键,合成器在按下时通知它。这个 PR 用它把设置里的映射接到 Hyprland 上,触发键由流界自动注册和绑定,用户不用去合成器里手写 bind。改了什么
crates/flow-platform/src/linux_hypr_shortcuts.rsregister_shortcut(id, appid, 说明, 触发键);按下时回调引擎。hyprctl把触发键绑成global, app.flowacross.desktop:<id>,按物理键位(code:<xkb 键码>),和流界其他地方一样与键盘布局无关。hyprctl eval 'hl.bind(…)';更早的版本自动回退到hyprctl keyword bind(启动时用hyprctl eval 'return 1'探测)。.socket2.sock,收到configreloaded自动重绑;退出时撤销注册和绑定。crates/flow-platform/protocols/(BSD-3-Clause,版权头保留),编译时用 wayland-scanner 生成绑定。flow-platform新增公开的LocalShortcut、set_local_shortcuts、set_local_shortcut_handler、desktop_shortcuts();Limits增加local_mapping,把「看不到本机键盘」和「映射在本机做不到」分开。sync_input每次同步时重算注册表,只注册现在真的发得出去的映射(目标连着、对方版本认得Message::KeyStroke、共享没暂停);不带修饰键又不是功能键的按键不注册(不能把它从所有程序手里抢走)。按下后走Controller::run_shortcut,和本机捕获是同一条发送路径;发送失败时限频提示。退出时清理注册。测试
cargo fmt --all、cargo clippy --workspace --all-targets -- -D warnings、cargo test --workspace(在 X11 环境变量下跑,和 CI 的 Ubuntu 任务一致)、cd app && npm run build全部通过;新增了按键格式、过滤、Lua 转义、只注册可发送映射等单元测试。hyprctl globalshortcuts能看到映射,hyprctl binds里能按到对应的全局绑定;hyprctl reload之后流界自动重绑;退出后两者都消失。需要注意
/usr/share/hyprland-protocols读取,但那样构建会依赖本机装了 hyprland-protocols。